package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhmoveInwhItemDAO;
import com.cssy.yd.logic.entity.LogicWhmoveInwhItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicWhmoveInwhItemDAOImpl extends SqlMapClientDaoSupport implements LogicWhmoveInwhItemDAO {

    /**
     * 插入数据
     * @param logicWhmoveInwhItemDO
     * @return 插入数据的主键
     */
    public String insertLogicWhmoveInwhItemDO(LogicWhmoveInwhItemDO logicWhmoveInwhItemDO) throws DataAccessException {
        Object ID = getSqlMapClientTemplate().insert("LogicWhmoveInwhItem.insert", logicWhmoveInwhItemDO);
        return (String) ID;
    }

    /**
     * 统计记录数
     * @param logicWhmoveInwhItemDO
     * @return 查出的记录数
     */
    public Integer countLogicWhmoveInwhItemDOByExample(LogicWhmoveInwhItemDO logicWhmoveInwhItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwhItem.countByDOExample", logicWhmoveInwhItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhmoveInwhItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhmoveInwhItemDO(LogicWhmoveInwhItemDO logicWhmoveInwhItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWhmoveInwhItem.update", logicWhmoveInwhItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhmoveInwhItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhmoveInwhItemDO> findListByExample(LogicWhmoveInwhItemDO logicWhmoveInwhItemDO) throws DataAccessException {
        List<LogicWhmoveInwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveInwhItem.findListByDO", logicWhmoveInwhItemDO);
        return list;
    }

    /**
     * 根据主键获取logicWhmoveInwhItemDO
     * @param id
     * @return logicWhmoveInwhItemDO
     */
    public LogicWhmoveInwhItemDO findLogicWhmoveInwhItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhmoveInwhItemDO logicWhmoveInwhItemDO = (LogicWhmoveInwhItemDO) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwhItem.findByPrimaryKey", id);
        return logicWhmoveInwhItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhmoveInwhItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhmoveInwhItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhmoveInwhItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhmoveInwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveInwhItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwhItem_ex.count", scs);
  	      return count;
  	}

	@Override
	public List<LogicWhmoveInwhItemDO> findItemListByLogicWhmoveInwhId(String id)
			throws DataAccessException {
		List<LogicWhmoveInwhItemDO> logicWhmoveInwhItemDOList = getSqlMapClientTemplate().queryForList("LogicWhmoveInwhItem.findByOtherInWhId", id);
    	return logicWhmoveInwhItemDOList;
	}

	@Override
	public Integer deleteLogicWhmoveInwhItemDOByOtherInWhId(String otherWhId)
			throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhmoveInwhItem.deleteByOtherInWhId", otherWhId);
    	return rows;
	}

	@Override
	public Double findYjsQuantityByOricode(SearchConditions scs) throws DataAccessException {
		Double yjsQuantity = (Double) getSqlMapClientTemplate().queryForObject("LogicWhmoveInwhItem_ex.findYjsQuantityByOricode", scs);
		return yjsQuantity;
	}
}